package com.lifang.framework.beans.factory;

import java.util.ArrayList;
import java.util.List;

/**
 * bean属性集合定义
 */
public class PropertyValues {

    private final Class<?> targetClass;

    public PropertyValues(Class<?> targetClass) {
        this.targetClass = targetClass;
    }

    private final List<PropertyValue> propertyValueList = new ArrayList<>();

    public void addPropertyValue(PropertyValue propertyValue) {
        propertyValueList.add(propertyValue);
    }

    public List<PropertyValue> getPropertyValues() {
        return this.propertyValueList;
    }

    public PropertyValue getPropertyValue(String propertyName) {
        for (PropertyValue propertyValue : this.propertyValueList) {
            if (propertyValue.getName().equals(propertyName)) {
                return propertyValue;
            }
        }
        return null;
    }

    public boolean needsRefresh(Class<?> targetClass){
        return this.targetClass == targetClass;
    }

}
